import 'package:enterprise_v6_app/app/components/special_operation/custom_icon_title_view.dart';
import 'package:enterprise_v6_app/app/components/toast_widget.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/ext/widget_extension.dart';
import 'package:enterprise_v6_app/app/modules/application/special_operation/special_list/job_ticket/common/common_process/common_gas_analysis/common_gas_analysis_controller.dart';
import 'package:enterprise_v6_app/app/modules/application/special_operation/special_list/job_ticket/common/common_process/common_gas_analysis/common_sampling_analysis/common_sampling_analysis_view.dart';

///作业通用-气体分析
class CommonGasAnalysisPage extends StatelessWidget {
  CommonGasAnalysisPage({
    required this.isEnabled,
    required this.isChange,
    required this.businessType,
    super.key,
  });

  //节点是否可编辑
  final bool isEnabled;

  // 是否在交接班中
  final bool isChange;

  // 节点类型 1：动火作业 2：受限空间作业 3：盲板抽堵作业 4：高处作业 5：吊装作业 6：临时用电作业 7：动土作业 8：断路作业
  final String businessType;

  final controller = Get.put(CommonGasAnalysisController());

  ///取样方式
  Widget _getSamplingMethodView() {
    return Container(
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(8.w),
        ),
        child: Column(
          children: [
            const CustomIconTitleView(
              title: '取样方式',
            ),
            Container(
              color: const Color(0xFFF5F7FC),
              height: 1.w,
            ),
            Obx(() {
              return Container(
                padding: EdgeInsets.symmetric(horizontal: 12.w),
                height: 70.w,
                child: Stack(
                  alignment: Alignment.center,
                  children: [
                    Positioned(
                      left: 0,
                      child: SvgPicture.asset(
                        controller.currentIndex.value == 0
                            ? AppImages.icon_field_sampling
                            : AppImages.icon_un_field_sampling,
                        width: 143.w,
                        height: 40.w,
                      ).clickOnce(() {
                        controller.selectTitle(0);
                      }),
                    ),
                    Positioned(
                      right: 0,
                      child: SvgPicture.asset(
                        controller.currentIndex.value == 0
                            ? AppImages.icon_un_access_device
                            : AppImages.icon_access_device,
                        width: 143.w,
                        height: 40.w,
                      ).clickOnce(() {
                        AppToast.show('功能等待接入~');
                        // controller.selectTitle(1);
                      }),
                    ),
                  ],
                ),
              );
            }),
          ],
        ));
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 14.w, vertical: 12.w),
      margin: EdgeInsets.only(bottom: 60.w),
      color: const Color(0xFFF5F5F6),
      alignment: Alignment.topCenter,
      child: Column(
        children: [
          //取样方式
          _getSamplingMethodView(),
          AppGaps.vGap20,
          Expanded(
              child: PageView(
            physics: const NeverScrollableScrollPhysics(), // 禁止滑动
            controller: controller.pageController,
            onPageChanged: controller.selectTitle,
            children: [
              CommonSamplingAnalysisPage(
                isEnabled: isEnabled,
                businessType: businessType,
              ),
              Container(
                color: Colors.blue,
              ),
            ],
          )),
        ],
      ),
    );
  }
}
